const pool = require("../connection/sqlPool");

async function ADDTOPIC(subject,optionA,optionB,optionC,optionD,right_key,attribute,provider){
    const promisePool = pool.promise();
    try{
        const [rows,fields] = await promisePool.query(
            'INSERT INTO `Subject_review`(`subject`,`optionA`,`optionB`,`optionC`,`optionD`,`right_key`,`attribute`,`provider`)VALUES(?,?,?,?,?,?,?,?)',
            [subject,optionA,optionB,optionC,optionD,right_key,attribute,provider]
        )
        const [rows_l,fields_l] = await promisePool.query(
            'UPDATE `user_message` SET `level_num` = `level_num` + 50 WHERE `username` = ?',
            [provider]
        );
        return {rows,rows_l,provider:provider}
    }catch(error){
        return error.message;
    }
}          

module.exports = {ADDTOPIC}